.class public Lcom/ss/android/socialbase/appdownloader/j;
.super Ljava/lang/Object;
.source "InstallQueue.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/ss/android/socialbase/appdownloader/j$e;
    }
.end annotation


# instance fields
.field private a:Ljava/util/Queue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Queue<",
            "Ljava/lang/Integer;",
            ">;"
        }
    .end annotation
.end field

.field private b:Z

.field private c:J

.field private d:J

.field private e:Landroid/os/Handler;

.field private f:Ljava/lang/Runnable;


# direct methods
.method private constructor <init>()V
    .locals 2

    .line 2
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 3
    new-instance v0, Ljava/util/ArrayDeque;

    invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V

    iput-object v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->a:Ljava/util/Queue;

    const/4 v0, 0x0

    .line 4
    iput-boolean v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->b:Z

    .line 5
    new-instance v0, Landroid/os/Handler;

    invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

    move-result-object v1

    invoke-direct {v0, v1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

    iput-object v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->e:Landroid/os/Handler;

    .line 6
    new-instance v0, Lcom/ss/android/socialbase/appdownloader/j$a;

    invoke-direct {v0, p0}, Lcom/ss/android/socialbase/appdownloader/j$a;-><init>(Lcom/ss/android/socialbase/appdownloader/j;)V

    iput-object v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->f:Ljava/lang/Runnable;

    .line 7
    invoke-static {}, Les/hm0;->c()Les/hm0;

    move-result-object v0

    new-instance v1, Lcom/ss/android/socialbase/appdownloader/j$b;

    invoke-direct {v1, p0}, Lcom/ss/android/socialbase/appdownloader/j$b;-><init>(Lcom/ss/android/socialbase/appdownloader/j;)V

    invoke-virtual {v0, v1}, Les/hm0;->a(Les/hm0$b;)V

    return-void
.end method

.method synthetic constructor <init>(Lcom/ss/android/socialbase/appdownloader/j$a;)V
    .locals 0

    .line 1
    invoke-direct {p0}, Lcom/ss/android/socialbase/appdownloader/j;-><init>()V

    return-void
.end method

.method static synthetic a(Lcom/ss/android/socialbase/appdownloader/j;Landroid/content/Context;IZ)I
    .locals 0

    .line 1
    invoke-direct {p0, p1, p2, p3}, Lcom/ss/android/socialbase/appdownloader/j;->b(Landroid/content/Context;IZ)I

    move-result p0

    return p0
.end method

.method static synthetic a(Lcom/ss/android/socialbase/appdownloader/j;J)J
    .locals 0

    .line 2
    iput-wide p1, p0, Lcom/ss/android/socialbase/appdownloader/j;->d:J

    return-wide p1
.end method

.method public static a()Lcom/ss/android/socialbase/appdownloader/j;
    .locals 1

    .line 6
    invoke-static {}, Lcom/ss/android/socialbase/appdownloader/j$e;->a()Lcom/ss/android/socialbase/appdownloader/j;

    move-result-object v0

    return-object v0
.end method

.method static synthetic a(Lcom/ss/android/socialbase/appdownloader/j;)V
    .locals 0

    .line 3
    invoke-direct {p0}, Lcom/ss/android/socialbase/appdownloader/j;->b()V

    return-void
.end method

.method private b(Landroid/content/Context;IZ)I
    .locals 0

    .line 10
    invoke-static {p1, p2, p3}, Lcom/ss/android/socialbase/appdownloader/d;->b(Landroid/content/Context;IZ)I

    move-result p1

    const/4 p2, 0x1

    if-ne p1, p2, :cond_0

    .line 11
    iput-boolean p2, p0, Lcom/ss/android/socialbase/appdownloader/j;->b:Z

    .line 12
    :cond_0
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide p2

    iput-wide p2, p0, Lcom/ss/android/socialbase/appdownloader/j;->c:J

    return p1
.end method

.method static synthetic b(Lcom/ss/android/socialbase/appdownloader/j;)J
    .locals 2

    .line 1
    iget-wide v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->d:J

    return-wide v0
.end method

.method private b()V
    .locals 5

    .line 2
    iget-object v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->a:Ljava/util/Queue;

    invoke-interface {v0}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Integer;

    .line 3
    iget-object v1, p0, Lcom/ss/android/socialbase/appdownloader/j;->e:Landroid/os/Handler;

    iget-object v2, p0, Lcom/ss/android/socialbase/appdownloader/j;->f:Ljava/lang/Runnable;

    invoke-virtual {v1, v2}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V

    const/4 v1, 0x0

    if-eqz v0, :cond_1

    .line 4
    invoke-static {}, Lcom/ss/android/socialbase/downloader/downloader/c;->b()Landroid/content/Context;

    move-result-object v2

    .line 5
    invoke-static {}, Landroid/os/Looper;->myLooper()Landroid/os/Looper;

    move-result-object v3

    invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

    move-result-object v4

    if-eq v3, v4, :cond_0

    .line 6
    iget-object v1, p0, Lcom/ss/android/socialbase/appdownloader/j;->e:Landroid/os/Handler;

    new-instance v3, Lcom/ss/android/socialbase/appdownloader/j$c;

    invoke-direct {v3, p0, v2, v0}, Lcom/ss/android/socialbase/appdownloader/j$c;-><init>(Lcom/ss/android/socialbase/appdownloader/j;Landroid/content/Context;Ljava/lang/Integer;)V

    invoke-virtual {v1, v3}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    goto :goto_0

    .line 7
    :cond_0
    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    invoke-direct {p0, v2, v0, v1}, Lcom/ss/android/socialbase/appdownloader/j;->b(Landroid/content/Context;IZ)I

    .line 8
    :goto_0
    iget-object v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->e:Landroid/os/Handler;

    iget-object v1, p0, Lcom/ss/android/socialbase/appdownloader/j;->f:Ljava/lang/Runnable;

    const-wide/16 v2, 0x4e20

    invoke-virtual {v0, v1, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

    goto :goto_1

    .line 9
    :cond_1
    iput-boolean v1, p0, Lcom/ss/android/socialbase/appdownloader/j;->b:Z

    :goto_1
    return-void
.end method

.method private c()Z
    .locals 5

    .line 1
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    iget-wide v2, p0, Lcom/ss/android/socialbase/appdownloader/j;->c:J

    sub-long/2addr v0, v2

    const-wide/16 v2, 0x3e8

    cmp-long v4, v0, v2

    if-gez v4, :cond_0

    const/4 v0, 0x1

    goto :goto_0

    :cond_0
    const/4 v0, 0x0

    :goto_0
    return v0
.end method


# virtual methods
.method public a(Landroid/content/Context;IZ)I
    .locals 4

    if-eqz p3, :cond_0

    .line 7
    invoke-direct {p0, p1, p2, p3}, Lcom/ss/android/socialbase/appdownloader/j;->b(Landroid/content/Context;IZ)I

    move-result p1

    return p1

    .line 8
    :cond_0
    invoke-direct {p0}, Lcom/ss/android/socialbase/appdownloader/j;->c()Z

    move-result v0

    const/4 v1, 0x1

    if-eqz v0, :cond_1

    .line 9
    iget-object v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->e:Landroid/os/Handler;

    new-instance v2, Lcom/ss/android/socialbase/appdownloader/j$d;

    invoke-direct {v2, p0, p1, p2, p3}, Lcom/ss/android/socialbase/appdownloader/j$d;-><init>(Lcom/ss/android/socialbase/appdownloader/j;Landroid/content/Context;IZ)V

    const-wide/16 p1, 0x3e8

    invoke-virtual {v0, v2, p1, p2}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

    return v1

    .line 10
    :cond_1
    invoke-static {}, Les/hm0;->c()Les/hm0;

    move-result-object v0

    invoke-virtual {v0}, Les/hm0;->b()Z

    move-result v0

    if-eqz v0, :cond_2

    .line 11
    invoke-direct {p0, p1, p2, p3}, Lcom/ss/android/socialbase/appdownloader/j;->b(Landroid/content/Context;IZ)I

    move-result p1

    return p1

    .line 12
    :cond_2
    iget-object v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->a:Ljava/util/Queue;

    invoke-interface {v0}, Ljava/util/Queue;->isEmpty()Z

    move-result v0

    if-eqz v0, :cond_3

    iget-boolean v0, p0, Lcom/ss/android/socialbase/appdownloader/j;->b:Z

    if-nez v0, :cond_3

    .line 13
    invoke-direct {p0, p1, p2, p3}, Lcom/ss/android/socialbase/appdownloader/j;->b(Landroid/content/Context;IZ)I

    move-result p1

    return p1

    .line 14
    :cond_3
    invoke-static {}, Les/jo0;->b()Les/jo0;

    move-result-object p1

    const/4 p3, 0x3

    const-string v0, "install_queue_size"

    invoke-virtual {p1, v0, p3}, Les/jo0;->a(Ljava/lang/String;I)I

    move-result p1

    .line 15
    :goto_0
    iget-object p3, p0, Lcom/ss/android/socialbase/appdownloader/j;->a:Ljava/util/Queue;

    invoke-interface {p3}, Ljava/util/Queue;->size()I

    move-result p3

    if-le p3, p1, :cond_4

    .line 16
    iget-object p3, p0, Lcom/ss/android/socialbase/appdownloader/j;->a:Ljava/util/Queue;

    invoke-interface {p3}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    goto :goto_0

    .line 17
    :cond_4
    iget-object p1, p0, Lcom/ss/android/socialbase/appdownloader/j;->e:Landroid/os/Handler;

    iget-object p3, p0, Lcom/ss/android/socialbase/appdownloader/j;->f:Ljava/lang/Runnable;

    invoke-virtual {p1, p3}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V

    .line 18
    invoke-static {p2}, Les/jo0;->a(I)Les/jo0;

    move-result-object p1

    const-wide/16 v2, 0x4e20

    const-string p3, "install_queue_timeout"

    invoke-virtual {p1, p3, v2, v3}, Les/jo0;->a(Ljava/lang/String;J)J

    move-result-wide v2

    .line 19
    iget-object p1, p0, Lcom/ss/android/socialbase/appdownloader/j;->e:Landroid/os/Handler;

    iget-object p3, p0, Lcom/ss/android/socialbase/appdownloader/j;->f:Ljava/lang/Runnable;

    invoke-virtual {p1, p3, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

    .line 20
    iget-object p1, p0, Lcom/ss/android/socialbase/appdownloader/j;->a:Ljava/util/Queue;

    invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p3

    invoke-interface {p1, p3}, Ljava/util/Queue;->contains(Ljava/lang/Object;)Z

    move-result p1

    if-nez p1, :cond_5

    .line 21
    iget-object p1, p0, Lcom/ss/android/socialbase/appdownloader/j;->a:Ljava/util/Queue;

    invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p2

    invoke-interface {p1, p2}, Ljava/util/Queue;->offer(Ljava/lang/Object;)Z

    :cond_5
    return v1
.end method

.method a(Les/zn0;Ljava/lang/String;)V
    .locals 0

    if-eqz p1, :cond_0

    .line 4
    invoke-static {p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result p1

    if-nez p1, :cond_0

    .line 5
    invoke-direct {p0}, Lcom/ss/android/socialbase/appdownloader/j;->b()V

    :cond_0
    return-void
.end method
